import { createSlice } from "@reduxjs/toolkit";
import dayjs from "dayjs";

const Cityslice = createSlice({
  name: "Cityslice",
  initialState: {
    start:"北京",
    end:"广州",
    date:dayjs().format("YYYY-MM-DD")
  },
  reducers: {
    //城市交换
    EXchangeCity(state){
      const tt=state.start
      state.start=state.end
      state.end=tt
    },

    editchangeTime(state,{payload}){
      state.date=payload.date
    },

    editChangeCity(state,{payload}){
      state[payload.type]=payload.city
    }
  },
});

// Action creators are generated for each case reducer function
export const { EXchangeCity,editchangeTime,editChangeCity } = Cityslice.actions;

export default Cityslice.reducer;
